﻿var index = 0;
// code 为弹窗编码
// type 为选择类型 0为列表单选，1为列表多选，2为树多选，3为树单选
// rowIndex 为当前页面有多个弹出框的时候进行区分
// param 默认查询参数，JSON格式，在sql语句Xml写对应的判断语句
function sysSelect_onClick(cont, code, type, rowIndex, width, height, param) {
	var url = GetLocationUrl(cont + '/sysSelect/select');// 列表多选
	if (!width) {
		width = '800px';
	}
	if (!height) {
		height = '500px';
	}
	index = rowIndex;
	var ids = "";
	$(":input").each(function(a, b) {
		var name = $(b).attr("sysSelectResultName");
		if (typeof (name) != "undefined") {
			var len = name.indexOf("result1");
			if (len > -1) {
				if (index) {
					len = name.indexOf("_" + index);
					if (len > 0) {
						ids = $(b).val();
					}
				} else {
					ids = $(b).val();
				}
			}
		}
	});

	url += "?code=" + code + "&pageNum=" + type + "&arg=," + ids + ",";
	if (param) {
		url += "&isfirst=is&defaultParam=" + encodeURI(encodeURI(param));
	}
	console.log(url);
	layer.open({
		type : 2,
		title : '弹框选择',
		shadeClose : true,
		shade : 0.8,
		area : [ width, height ],
		content : url
	});
}

function selectCustom_onClick(url, rowIndex) {
	var url = GetLocationUrl(url);

	index = rowIndex;
	layer.open({
		type : 2,
		title : '弹框选择',
		shadeClose : true,
		shade : 0.8,
		area : [ '800px', '600px' ],
		content : url
	});
}

function sysSelect_getlay(data, array) {
	$(":input").each(function(a, b) {
		var name = $(b).attr("sysSelectResultName");
		if (typeof (name) != "undefined") {
			if (index) {
				var len = name.indexOf("_" + index);
				if (len > 0) {
					$(b).val(data[name.substring(0, len)]);
				}
			} else {
				$(b).val(data[name]);
			}

		}
	});
}

// 获取指定页面完整URL地址
function GetLocationUrl(url) {

	var LocationUrl = "";
	LocationUrl = top.window.location.host;
	LocationUrl = "http://" + LocationUrl + url;
	return LocationUrl;
}